<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Index_My extends Controller_Index_Base
{
    protected $_need_auth = true;
    
    public function action_index()
    {   
        if (HTTP_Request::POST == $this->request->method()) {
            $payment_method  = $this->request->post('payment_method');
            $payment_account = $this->request->post('payment_account');
  
            try {
                $user = Model_Auth::instance()->get_user();
                $user->payment_method  = $payment_method;
                $user->payment_account = $payment_account;
                $user->save();
            } catch (Exception $e) {
                $message = 'Форма заполнена с ошибками!';
            }
        }
            
        $content = new View('index/my/index_tpl');
        $content->payment_methods = Model_Payment::get_available_payment_methods();
        
        $this->print_template('Мой StyleGarderob', $content);
    }
    
    public function action_clicks()
    {  
        $clicks = ORM::factory('click')->get_last_clicks();
             
        $content = new View('index/my/clicks_tpl');
        $content->clicks = $clicks;
        $content->shops  = ORM::factory('shop')->get_shops_by_clicks($clicks);
        
        $this->print_template('История кликов на StyleGarderob', $content);
    }
    
    public function action_orders()
    {           
        $content = new View('index/my/orders_tpl');
        
        $this->print_template('Ваши покупки на StyleGarderob', $content);
    }
    
    public function action_payments()
    {           
        $content = new View('index/my/payments_tpl');
        
        $this->print_template('Ваши платежи на StyleGarderob', $content);
    }
    
    public function action_partner()
    {           
        $content = new View('index/my/partner_tpl');
        $content->categories = ORM::factory('category')->get_main_categories();
        
        $this->print_template('Партнерская программа StyleGarderob', $content);
    }
    
    public function action_support()
    {           
        $content = new View('index/my/support_tpl');
        
        $this->print_template('Поддержка StyleGarderob', $content);
    }
} 
